#!/usr/bin/env bash

set -e

CMD=$1;
if [ -z "$CMD" ]; then
    CMD="up -d"
else
    shift
fi

# Re-create environment
make env

if [ "$CMD" == "reset" ]; then
    # Purge docker containers/volumes
    make reset
    exit 0
elif [ "$CMD" == "build" ]; then
    # install or update base images, to be sure we have the latest images
    docker compose pull
    # install or update plugins, to be sure we have the latest plugins
    make build-plugins
fi

docker compose $CMD "$@"
